<?php

class BaseController extends Controller {

    /**
     * Setup the layout used by the controller.
     *
     * @return void
     */
    protected function setupLayout()
    {
        if ( ! is_null($this->layout))
        {
            $this->layout = View::make($this->layout);
        }
    }

    public function __construct() {
        // Menu
        $manufacturers  = Manufacturer::getListMenu();
        $categories     = Category::getListMenu();
        $categoriesBestSell  = Category::categoriesBestSell();

        View::share('categoriesBestSell', $categoriesBestSell);
        View::share('categories', $categories);
        View::share('manufacturers', $manufacturers);

        if (Auth::check()) {
            $routeAction    =  preg_split("/@/", Route::currentRouteAction());
            $controllerName =  isset($routeAction[0]) ? $routeAction[0]: '';
            $actionName     = isset($routeAction[1]) ? $routeAction[1]: '';
            // to layout header na
            View::share('controllerName', $controllerName);
            View::share('actionName', $actionName);
        }
    }
}
